<?php if (isset($fgame) && $fgame) { ?>
<a href="<?php echo base_module_url('user_game_favorites', 'remove_favorite/'. $fgame->game_id); ?>" rel="nofollow" id="remove_favorite" class="btn_favorite">
	<img  title="Remove to favorites"  src="<?php echo $this->template->url_theme;?>images/remove.png"  alt="remove to favorites" class="favoritos">
</a>  

<?php } else { ?>

<a href="<?php echo base_module_url('user_game_favorites', 'add_favorite/'. $game_id); ?>" rel="nofollow" id="add_favorite" class="btn_favorite">
	<img  title="Add to favorites"  src="<?php echo $this->template->url_theme;?>images/add.png"  class="favoritos">
</a> 
<?php 
}?>  

<script type="text/javascript">
	$(function (){ 
		$('.btn_favorite').click(function(){
			var dis = this;
			$.post(this.href, {}, function (re){});
			if (dis.href.match('add_favorite')) {
				dis.href = dis.href.replace('add_favorite', 'remove_favorite');
				$(dis).find('img')[0].src = $(dis).find('img')[0].src.replace('add.png', 'remove.png');
				$(dis).find('img').attr('title', 'Remove to favorites');
			}
			else  {
				dis.href = dis.href.replace('remove_favorite', 'add_favorite');
				$(dis).find('img')[0].src = $(dis).find('img')[0].src.replace('remove.png', 'add.png');
				$(dis).find('img').attr('title', 'Add to favorites');
			}
			
			return false;
		});
	});
</script>
<style type="text/css">.btn_favorite img {margin-top: -6px;}</style>